home *** CD-ROM | disk | FTP | other *** search
/ Macworld Expo - Develope…Central & Net Innovations / Developer Central and Net Innovators (MacWorld Expo) (January 1999).iso / Developer Central / Bowers Development / Demo AppMaker / Examples / PowerPlant / Everything / CModelessRadios.cp < prev    next >
Encoding:
Text File  |  1998-10-11  |  8.1 KB  |  436 lines  |  [TEXT/CWIE]

  1. // CModelessRadios.cp -- dialog methods
  2.  
  3. #include "CModelessRadios.h"
  4.  
  5. #include <UEnvironment.h>
  6. #include <UReanimator.h>
  7. #include <URegistrar.h>
  8. #include <LStream.h>
  9. #include <LTabGroup.h>
  10. #include <LRadioGroupView.h>
  11. #include <LRadioButton.h>
  12. #include <LAMControlImp.h>
  13. #include <LGARadioButtonImp.h>
  14. #include <LTextGroupBox.h>
  15. #include <LAMControlViewImp.h>
  16. #include <LGATextGroupBoxImp.h>
  17. #include <CustomControls.h>
  18. #include <LBevelButton.h>
  19. #include <LAMBevelButtonImp.h>
  20. #include <LGABevelButtonImp.h>
  21. #include <LTextButton.h>
  22. #include <CTextUtils.h>
  23.  
  24. #include "DModelessRadiosData.h"
  25. #include "EverythingCmds.h"
  26. #include <PP_Messages.h>
  27.  
  28.  
  29. #define PPob_ModelessRadiosID    216
  30. #define RidL_ModelessRadiosID    216
  31.  
  32. Boolean        CModelessRadios::sIsRegistered = false;
  33.  
  34. //----------
  35. CModelessRadios*        CModelessRadios::CreateModelessRadios (
  36.     LCommander*        inSuperCommander,
  37.     CommandT        inCommand,
  38.     DModelessRadiosData*        inData)
  39. {
  40.     if (!sIsRegistered) {
  41.         RegisterClass ();
  42.     }
  43.     CModelessRadios*        dlog;
  44.     dlog = ((CModelessRadios *)LWindow::CreateWindow(PPob_ModelessRadiosID, inSuperCommander));
  45.     dlog->mCommand = inCommand;
  46.     dlog->SetFromData (inData);
  47.  
  48.     return dlog;
  49. }
  50.  
  51. //----------
  52. #define    RegisterClasses(AbstractClass,AMImpClass,GAImpClass)    \
  53.     RegisterClass_(AbstractClass);    \
  54.     if (useAppearance) {    \
  55.         RegisterClassID_(AMImpClass, AbstractClass::imp_class_ID);    \
  56.     } else {    \
  57.         RegisterClassID_(GAImpClass, AbstractClass::imp_class_ID);    \
  58.     }
  59.  
  60. //----------
  61. void    CModelessRadios::RegisterClass ()
  62. {
  63.     Boolean        useAppearance = UEnvironment::HasFeature (env_HasAppearance);
  64.  
  65.     RegisterClass_(CModelessRadios);
  66.  
  67.     // register the pane classes we use
  68.     RegisterClass_(LRadioGroupView);
  69.     RegisterClasses (LRadioButton, LAMControlImp, LGARadioButtonImp);
  70.     RegisterClasses (LTextGroupBox, LAMControlViewImp, LGATextGroupBoxImp);
  71.     RegisterClasses (CRadioButton, CustomControlImp, CustomControlImp);
  72.     RegisterClasses (LBevelButton, LAMBevelButtonImp, LGABevelButtonImp);
  73.     RegisterClass_(LTextButton);
  74.  
  75.     sIsRegistered = true;
  76. }
  77.  
  78. //----------
  79. CModelessRadios::CModelessRadios (
  80.     LStream*    inStream)
  81.     : LGADialog (inStream)
  82. {
  83.     mData = nil;
  84. }
  85.  
  86. //----------
  87. CModelessRadios::~CModelessRadios()
  88. {
  89.     delete mData;
  90. }
  91.  
  92. //----------
  93. //    This member function gets called once the containment hierarchy that contains
  94. //    this pane has been built. It gives us a chance to get data members for
  95. //    interesting subviews, and to do other operations now that our subviews exist.
  96. void    CModelessRadios::FinishCreateSelf()
  97. {
  98.     LGADialog::FinishCreateSelf();
  99.  
  100.     mRadioGroupGroup = (LRadioGroupView*) FindPaneByID ('Radp');
  101.  
  102.     mStandardRadio = (LRadioButton*) FindPaneByID ('Stad');
  103.  
  104.     mGroupGroup = (LRadioGroupView*) FindPaneByID ('Grop');
  105.  
  106.     mGraphicGroup = (LRadioGroupView*) FindPaneByID ('Grac');
  107.  
  108.     mStopRadio = (CRadioButton*) FindPaneByID ('Stop');
  109.  
  110.     mGoRadio = (CRadioButton*) FindPaneByID ('Go  ');
  111.  
  112.     mBevelGroup = (LRadioGroupView*) FindPaneByID ('Bevl');
  113.  
  114.     mRadioButtonRadio = (LBevelButton*) FindPaneByID ('Radn');
  115.  
  116.     mRadioButton2Radio = (LBevelButton*) FindPaneByID ('Rad2');
  117.  
  118.     mTextGroup = (LRadioGroupView*) FindPaneByID ('Text');
  119.  
  120.     mNameRadio = (LTextButton*) FindPaneByID ('Name');
  121.  
  122.     mKindRadio = (LTextButton*) FindPaneByID ('Kind');
  123.  
  124.     mSizeRadio = (LTextButton*) FindPaneByID ('Size');
  125.  
  126.  
  127.     UReanimator::LinkListenerToControls(this, this, RidL_ModelessRadiosID);
  128.         // the purpose is to "connect" self to whatever controls
  129.         // that we want to "listen" to
  130.  
  131. // any additional initialization for your dialog:
  132.  
  133. }
  134.  
  135. //----------
  136. void    CModelessRadios::SetFromData (
  137.     DModelessRadiosData*        inData)
  138. {
  139.     mData = inData;
  140.     mData->AddListener (this);
  141.  
  142.     mRadioGroupGroup->SetValue (mData->GetRadioGroup3 ());
  143.     mGroupGroup->SetValue (mData->GetGroup3 ());
  144.     mGraphicGroup->SetValue (mData->GetGraphic5 ());
  145.     mBevelGroup->SetValue (mData->GetBevel3 ());
  146.     mTextGroup->SetValue (mData->GetText3 ());
  147. }
  148.  
  149. //----------
  150. DModelessRadiosData*        CModelessRadios::GetData ()
  151. {
  152.  
  153.     return mData;
  154. }
  155.  
  156. //----------
  157. void    CModelessRadios::DataChanged (
  158.     long        inDataID)
  159. {
  160.     StopListening ();
  161.  
  162.     if (inDataID == idRadioGroup3) {
  163.         mRadioGroupGroup->SetValue (mData->GetRadioGroup3 ());
  164.     }
  165.     if (inDataID == idGroup3) {
  166.         mGroupGroup->SetValue (mData->GetGroup3 ());
  167.     }
  168.     if (inDataID == idGraphic5) {
  169.         mGraphicGroup->SetValue (mData->GetGraphic5 ());
  170.     }
  171.     if (inDataID == idBevel3) {
  172.         mBevelGroup->SetValue (mData->GetBevel3 ());
  173.     }
  174.     if (inDataID == idText3) {
  175.         mTextGroup->SetValue (mData->GetText3 ());
  176.     }
  177.  
  178.     StartListening ();
  179. }
  180.  
  181. //----------
  182. void    CModelessRadios::ListenToMessage (
  183.     MessageT    inMessage,
  184.     void        *ioParam)
  185. {
  186.     switch (inMessage) {
  187.     case msg_OK:
  188.             GetSuperCommander()->ProcessCommand(-mCommand, this);
  189.         break;
  190.  
  191.     case msg_Cancel:
  192.             DoClose();
  193.         break;
  194.  
  195.     case msgDataChanged:
  196.             DataChanged ((long)ioParam);
  197.         break;
  198.  
  199.  
  200.     default:
  201.           ; // do something
  202.         break;
  203.     }
  204. }
  205.  
  206. //----------
  207. Boolean        CModelessRadios::ObeyCommand (
  208.     CommandT    inCommand,
  209.     void*        ioParam)
  210. {
  211.     Boolean        cmdHandled = true;
  212.  
  213.     if (inCommand < 0) {
  214.         // modal dialog has finished
  215.  
  216.         switch (-inCommand) {
  217.         }
  218.  
  219.     } else {
  220.         switch (inCommand) {
  221.  
  222.         default:
  223.                 cmdHandled = LGADialog::ObeyCommand(inCommand, ioParam);
  224.             break;
  225.         }
  226.     }
  227.  
  228.     return cmdHandled;
  229. }
  230.  
  231. //----------
  232. void    CModelessRadios::FindCommandStatus (
  233.     CommandT    inCommand,
  234.     Boolean        &outEnabled,
  235.     Boolean        &outUsesMark,
  236.     Char16        &outMark,
  237.     Str255        outName)
  238. {
  239.     outUsesMark = false;
  240.  
  241.     switch (inCommand) {
  242.  
  243.     // +++ Add cases here for the commands you handle
  244.  
  245.     default:
  246.             LGADialog::FindCommandStatus(inCommand, outEnabled,
  247.                                             outUsesMark, outMark, outName);
  248.         break;
  249.     }
  250. }
  251.  
  252. // following functions will be obsoleted
  253. // retained only for backwards compatibility
  254. //----------
  255. Int32
  256. CModelessRadios::GetRadioGroupGroupChoice ()
  257. {
  258.     return mRadioGroupGroup->GetCurrentRadioID ();
  259. }
  260.  
  261. void
  262. CModelessRadios::SetRadioGroupGroupChoice (
  263.     Int32        choice)
  264. {
  265.     mRadioGroupGroup->SetCurrentRadioID (choice);
  266. }
  267.  
  268. //----------
  269. Boolean
  270. CModelessRadios::GetStandardValue ()
  271. {
  272.     return mStandardRadio->GetValue ();
  273. }
  274.  
  275. void
  276. CModelessRadios::SetStandardValue (
  277.     Boolean        inValue)
  278. {
  279.     mStandardRadio->SetValue (inValue);
  280. }
  281.  
  282. //----------
  283. Int32
  284. CModelessRadios::GetGroupGroupChoice ()
  285. {
  286.     return mGroupGroup->GetCurrentRadioID ();
  287. }
  288.  
  289. void
  290. CModelessRadios::SetGroupGroupChoice (
  291.     Int32        choice)
  292. {
  293.     mGroupGroup->SetCurrentRadioID (choice);
  294. }
  295.  
  296. //----------
  297. Int32
  298. CModelessRadios::GetGraphicGroupChoice ()
  299. {
  300.     return mGraphicGroup->GetCurrentRadioID ();
  301. }
  302.  
  303. void
  304. CModelessRadios::SetGraphicGroupChoice (
  305.     Int32        choice)
  306. {
  307.     mGraphicGroup->SetCurrentRadioID (choice);
  308. }
  309.  
  310. //----------
  311. Boolean
  312. CModelessRadios::GetStopValue ()
  313. {
  314.     return mStopRadio->GetValue ();
  315. }
  316.  
  317. void
  318. CModelessRadios::SetStopValue (
  319.     Boolean        inValue)
  320. {
  321.     mStopRadio->SetValue (inValue);
  322. }
  323.  
  324. //----------
  325. Boolean
  326. CModelessRadios::GetGoValue ()
  327. {
  328.     return mGoRadio->GetValue ();
  329. }
  330.  
  331. void
  332. CModelessRadios::SetGoValue (
  333.     Boolean        inValue)
  334. {
  335.     mGoRadio->SetValue (inValue);
  336. }
  337.  
  338. //----------
  339. Int32
  340. CModelessRadios::GetBevelGroupChoice ()
  341. {
  342.     return mBevelGroup->GetCurrentRadioID ();
  343. }
  344.  
  345. void
  346. CModelessRadios::SetBevelGroupChoice (
  347.     Int32        choice)
  348. {
  349.     mBevelGroup->SetCurrentRadioID (choice);
  350. }
  351.  
  352. //----------
  353. Boolean
  354. CModelessRadios::GetRadioButtonValue ()
  355. {
  356.     return mRadioButtonRadio->GetValue ();
  357. }
  358.  
  359. void
  360. CModelessRadios::SetRadioButtonValue (
  361.     Boolean        inValue)
  362. {
  363.     mRadioButtonRadio->SetValue (inValue);
  364. }
  365.  
  366. //----------
  367. Boolean
  368. CModelessRadios::GetRadioButton2Value ()
  369. {
  370.     return mRadioButton2Radio->GetValue ();
  371. }
  372.  
  373. void
  374. CModelessRadios::SetRadioButton2Value (
  375.     Boolean        inValue)
  376. {
  377.     mRadioButton2Radio->SetValue (inValue);
  378. }
  379.  
  380. //----------
  381. Int32
  382. CModelessRadios::GetTextGroupChoice ()
  383. {
  384.     return mTextGroup->GetCurrentRadioID ();
  385. }
  386.  
  387. void
  388. CModelessRadios::SetTextGroupChoice (
  389.     Int32        choice)
  390. {
  391.     mTextGroup->SetCurrentRadioID (choice);
  392. }
  393.  
  394. //----------
  395. Boolean
  396. CModelessRadios::GetNameValue ()
  397. {
  398.     return mNameRadio->GetValue ();
  399. }
  400.  
  401. void
  402. CModelessRadios::SetNameValue (
  403.     Boolean        inValue)
  404. {
  405.     mNameRadio->SetValue (inValue);
  406. }
  407.  
  408. //----------
  409. Boolean
  410. CModelessRadios::GetKindValue ()
  411. {
  412.     return mKindRadio->GetValue ();
  413. }
  414.  
  415. void
  416. CModelessRadios::SetKindValue (
  417.     Boolean        inValue)
  418. {
  419.     mKindRadio->SetValue (inValue);
  420. }
  421.  
  422. //----------
  423. Boolean
  424. CModelessRadios::GetSizeValue ()
  425. {
  426.     return mSizeRadio->GetValue ();
  427. }
  428.  
  429. void
  430. CModelessRadios::SetSizeValue (
  431.     Boolean        inValue)
  432. {
  433.     mSizeRadio->SetValue (inValue);
  434. }
  435.  
  436.